﻿using MediatR;
using StudyCompanion.IServices;

namespace StudyCompanion.Services.CommandHandlers;

/// <summary>
///     登录日志处理
/// </summary>
public class LogInLogCommandHandler : IRequestHandler<LogInLogCommand, bool>
{
    private readonly ILoginLogService _loginLogService;

    public LogInLogCommandHandler(ILoginLogService loginLogService)
    {
        _loginLogService = loginLogService;
    }

    /// <summary>
    /// </summary>
    /// <param name="request"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    public async Task<bool> Handle(LogInLogCommand request, CancellationToken cancellationToken)
    {
        var loginLog = request.LoginLogInputDto;
        return await _loginLogService.InsertAsync(loginLog);
    }
}